import { on } from 'events';
import axios from '../axios';

/** *********基金相关******** */
// 非货币基金历史业绩
export const getFundNvPerformanceTrans = (prodCode) => axios.post('dz-mall/r/product/getFundNvPerformanceTrans', {
  prodCode
});
// 货币基金历史业绩
export const getFundMMPerformanceTransLatest = (prodCode) => axios.post('dz-mall/r/product/getFundMMPerformanceTransLatest', {
  prodCode
});
// 非货币基金历史净值
export const getFundNetValList = ({ prodCode, pageSize, pageNum }) => axios.post('dz-mall/r/product/getFundNetValList', {
  prodCode,
  pageSize,
  pageNum,
});
// 货币基金历史七日年化
export const getFundMMPerformanceTrans = ({ prodCode, pageSize, pageNum }) => axios.post('dz-mall/r/product/getFundMMPerformanceTrans', {
  prodCode,
  pageSize,
  pageNum,
});
// 基金排行
export const getFundList = ({
  searchType, orderBy, orderType, pageSize, pageNum
}) => axios.post('dz-mall/r/product/getFundList', {
  pageSize,
  pageNum,
  searchType, // 基金类型，非必须
  orderBy, // 基金排序字段，非必须
  orderType, // 升序 or 降序，非必须
});
// 非货币基金业绩走势
export const getFundNetValueYieldTrend = ({ prodCode, dayNum }) => axios.post('dz-mall/r/product/getFundNetValueYieldTrend', {
  prodCode,
  dayNum,
});
// 货币基金七日年化/万份收益
export const getFundMMPerformanceTransByStartDay = ({ prodCode, dayNum }) => axios.post('dz-mall/r/product/getFundMMPerformanceTransByStartDay', {
  prodCode,
  dayNum,
});
// 基金资产配置
export const getFundAssetAllocation = (prodCode) => axios.post('dz-mall/r/product/getFundAssetAllocation', {
  prodCode
});
// QDII基金资产配置
export const getQDIIAssetAllocation = (prodCode) => axios.post('dz-mall/r/product/getQDIIAssetAllocation', {
  prodCode
});
// 基金行业投资
export const getFundInvestIndustry = (prodCode) => axios.post('dz-mall/r/product/getFundInvestIndustry', {
  prodCode
});
// QDII基金行业投资
export const getQDIIInvestIndustry = (prodCode) => axios.post('dz-mall/r/product/getQDIIInvestIndustry', {
  prodCode
});
// 基金重仓股票
export const getFundKeyStockPortfolio = (prodCode) => axios.post('dz-mall/r/product/getFundKeyStockPortfolio', {
  prodCode
});
// QDII基金重仓股票
export const getQDIIPortfolioDetail = (prodCode) => axios.post('dz-mall/r/product/getQDIIPortfolioDetail', {
  prodCode
});
// 基金重仓债券
export const getFundBondPortifolioDetail = (prodCode) => axios.post('dz-mall/r/product/getFundBondPortifolioDetail', {
  prodCode
});
// 基金规模变动
export const getFundMainFinancialIndexQ = ({ prodCode, num }) => axios.post('dz-mall/r/product/getFundMainFinancialIndexQ', {
  prodCode,
  num
});
// 基金份额变动
export const getFundSharesChange = ({ prodCode, num }) => axios.post('dz-mall/r/product/getFundSharesChange', {
  prodCode,
  num
});
// 基金持有人结构
export const getFundHolderInfo = ({ prodCode, num }) => axios.post('dz-mall/r/product/getFundHolderInfo', {
  prodCode,
  num
});
// 基金公告列表
export const getNotTextAnnouncement = ({
  prodCode, infoType, pageNum, pageSize
}) => axios.post('dz-mall/r/product/getNotTextAnnouncement', {
  prodCode,
  infoType,
  pageNum,
  pageSize
});
// 基金公告详情
export const getTextAnnouncement = (annId) => axios.post('dz-mall/r/product/getTextAnnouncement', {
  annId
});
// 基金经理
export const getFundManager = (prodCode) => axios.post('dz-mall/r/product/getFundManager', {
  prodCode
});
// 基金特色数据
export const getFundSpecialData = (prodCode) => axios.post('dz-mall/r/product/getFundSpecialData', {
  prodCode
});
/** *********获取基金产品ByCode******** */
export const getFundDetailByCode = (prodCode) => axios.post('dz-mall/r/product/getFundDetailByCode', {
  prodCode
});

/** *********查询基金费率******** */
export const getFundChargeRate = (prodCode) => axios.post('dz-mall/r/product/getFundChargeRate', {
  prodCode
});

/** *********基金产品的下订单******** */
export const doFundOrder = (params) => axios.post('dz-mall/r/order/fund/buy', {
  productCode: params.productCode,
  totPrice: params.orderPrice,
  orderChannel: params.orderChannel, // 业务类型，非必须
  recommendId: params.recommendId, // 拓展人id，非必须
  managerId: params.managerId// 理财经理id,非必须
}, {
  loading: true
});

/** *********撤销基金产品订单******** */
export const doFundRevoke = (params) => axios.post('dz-mall/r/order/fund/revoke', {
  allotDate: params.allotDate,
  allotNo: params.allotNo,
  entrustNo: params.entrustNo
}, {
  loading: true
});

/** *********基金产品转换******** */
export const fundTransform = (params) => axios.post('dz-mall/r/order/fund/fundTransform', {
  productCode: params.productCode,
  transformedCode: params.transformedCode,
  amount: params.amount,
  orderChannel: params.orderChannel, // 业务类型，非必须
}, {
  loading: true
});

/** *********基金产品分红设置******** */
export const setDividedType = (params) => axios.post('dz-mall/r/order/fund/setDividendType', {
  productCode: params.prodCode,
  dividendType: params.dividedType,
  taNo: params.prodtaNo
}, {
  loading: true
});

/** *********基金产品赎回份额******** */
export const fundRedeem = (params) => axios.post('dz-mall/r/order/fund/redeem', {
  productCode: params.productCode,
  amount: params.amount,
  orderChannel: params.orderChannel, // 非必须
  managerId: params.managerId // 非必须
}, {
  loading: true
});

/** *********获取基金定投列表(进行中)******** */
export const queryOnInvest = (params) => axios.post('dz-mall/r/order/fund/queryOnInvest', {
  allotno: params.allotno, // 非必传
  prodCode: params.prodCode // 非必传
}, {
  loading: true
});

/** *********获取基金定投列表(已终止)******** */
export const queryOffInvest = (params) => axios.post('dz-mall/r/order/fund/queryOffInvest', {
  allotno: params.allotno, // 非必传
  prodCode: params.prodCode // 非必传
}, {
  loading: true
});

/** *********查询每月定投金额******** */
export const investMonthAmount = () => axios.post('dz-mall/r/order/fund/investMonthAmount');

/** *********查询定投委托记录******** */
export const queryEntrusts = (allotno) => axios.post('dz-mall/r/order/fund/queryEntrusts', {
  allotno
});

/** *********查询定投委托记录******** */
export const nextPayDay = (params) => axios.post('dz-mall/r/order/fund/nextPayDay', {
  payDate: params.enFundDate,
  payUnit: params.payUnit
});

/** *********新增基金定投计划******** */
export const fundAddPlan = (params) => axios.post('dz-mall/r/order/fund/addPlan', {
  productCode: params.productCode,
  startDate: params.startDate,
  endDate: params.endDate,
  balance: params.balance,
  payDate: params.enFundDate,
  payUnit: params.payUnit
}, {
  loading: true
});

/** *********修改基金定投计划******** */
export const fundUpdatePlan = (params) => axios.post('dz-mall/r/order/fund/updatePlan', {
  productCode: params.productCode,
  allotno: params.allotno,
  startDate: params.startDate,
  endDate: params.endDate,
  balance: params.balance,
  payDate: params.enFundDate,
  payUnit: params.payUnit
}, {
  loading: true
});

/** *********删除基金定投计划******** */
export const fundDeletePlan = (params) => axios.post('dz-mall/r/order/fund/deletePlan', {
  productCode: params.productCode,
  allotno: params.allotno
}, {
  loading: true
});

/** *********行业热门板块******** */
export const getFundIndustryIndexGR = (fundTagCode) => axios.post('dz-mall/r/product/getFundIndustryIndexGR', {
  fundTagCode
});

/** *********概念热门板块******** */
export const getFundThemeIndexGR = (fundTagCode) => axios.post('dz-mall/r/product/getFundThemeIndexGR', {
  fundTagCode
});
/** *********发售中的首发基金******** */
export const getSubscriptionFunds = ({ pageSize, pageNum }) => axios.post('dz-mall/r/product/getSubscriptionFunds', {
  pageSize,
  pageNum,
});
